<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wechat_customer_data', function (Blueprint $table) {
            $table->id();
            $table->date('count_date')->nullable()->comment('统计日期');
            $table->string('corp_id', 50)->default('')->comment('企业ID');
            $table->string('user_id', 50)->default('')->comment('成员ID');
            $table->integer('new_apply_cnt')->default(0)->comment('发起申请数');
            $table->integer('new_contact_cnt')->default(0)->comment('新增客户数');
            $table->integer('chat_cnt')->default(0)->comment('聊天总数， 成员有主动发送过消息的单聊总数');
            $table->integer('message_cnt')->default(0)->comment('已回复聊天占比');
            $table->integer('negative_feedback_cnt')->default(0)->comment('删除/拉黑成员的客户数');
            $table->float('reply_percentage')->default(0.00)->comment('发送消息数，成员在单聊中发送的消息总数');
            $table->integer('avg_reply_time')->default(0)->comment('平均首次回复时长，单位为分钟');
            $table->timestamps();
        });


        Schema::create('wechat_chat_data', function (Blueprint $table) {
            $table->id();
            $table->date('count_date')->nullable()->comment('统计日期');
            $table->string('corp_id', 50)->default('')->comment('企业ID');
            $table->string('user_id', 50)->default('')->comment('成员ID');
            $table->string('owner', 50)->default('')->comment('群主ID');
            $table->integer('new_chat_cnt')->default(0)->comment('新增客户群数量');
            $table->integer('chat_total')->default(0)->comment('截至当天客户群总数量');
            $table->integer('chat_has_msg')->default(0)->comment('截至当天有发过消息的客户群数量');
            $table->integer('new_member_cnt')->default(0)->comment('客户群新增群人数');
            $table->integer('member_total')->default(0)->comment('截至当天客户群总人数');
            $table->integer('member_has_msg')->default(0)->comment('截至当天有发过消息的群成员数');
            $table->integer('msg_total')->default(0)->comment('截至当天客户群消息总数');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wechat_customer_data');
        Schema::dropIfExists('wechat_chat_data');
    }
};
